<?php

namespace common\core\component;

use yii\base\Component;

class Jsms extends Component
{
    public $key;

    public $secret;

    public $temp_id;

    protected $client;

    public function __construct($config = [])
    {
        parent::__construct($config);
        $this->client = new \JiGuang\JSMS($this->key, $this->secret, ['disable_ssl' => true]);
    }

    public function sendCode($mobile,$code)
    {
       $result =  $this->client->sendMessage($mobile, $this->temp_id, ['code'=>"{$code}"], $time = null, $sign_id = null);
       return $result['body'];
       // $this->client->sendCode($mobile,$code , $sign = null);
    }
}
